<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增用户')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="main-content">
        <form id="form-user-add" class="form-horizontal">
            <input name="centerId" type="hidden" id="centerId"/>
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">姓名：</label>
                        <div class="col-sm-8">
                            <input name="name" placeholder="请输入姓名" class="form-control" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">手机号码：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input id="phone" name="phone" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11">
                                <span class="input-group-addon"><i class="fa fa-mobile"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">性别：</label>
                        <div class="col-sm-8">
                            <select name="sex" class="form-control" >
                                <option value="">请选择</option>
                                <option value="1">男</option>
                                <option value="2">女</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">年级：</label>
                        <div class="col-sm-8">
                            <select name="grade" class="form-control" th:with="type=${@dict.getType('child_grade')}">
                                <option value="">请选择</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">出生日期：</label>
                        <div class="col-sm-8">
                            <input type="text" class="time-input form-control" id="birthdayStr" placeholder="出生日期" name="birthdayStr"/>
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">会员状态：</label>
                        <div class="col-sm-8">
                            <select name="isMember" th:with="type=${@dict.getType('member_status')}" class="form-control">
                                <option value="">请选择</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </div>
                    </div>
                </div>

            </div>
        </form>
    </div>
      
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script>
	    var prefix = ctx + "business/child";
	
        $("#form-user-add").validate({
        	onkeyup: false,
        	rules:{
        		// loginName:{
        		// 	minlength: 2,
        		// 	maxlength: 20
        		// },
        		// password:{
        		// 	minlength: 5,
        		// 	maxlength: 20
        		// },
                //
        		// phonenumber:{
        		// 	isPhone:true
        		// },
        	},
        	messages: {
                // "loginName": {
                //     remote: "用户已经存在"
                // },
        		// "phonenumber":{
                // 	remote: "手机号码已经存在"
        		// }
            },
            focusCleanup: true
        });

        function submitHandler() {
            var selectIndex = window.parent.document.getElementById('parentSchoolList').selectedIndex;
            if (selectIndex >= 0) {
                var centerId = window.parent.document.getElementById('parentSchoolList').options[selectIndex].value;
                document.getElementById("centerId").value = centerId;
            }else {
                $.modal.alertWarning("请选择机构");
                return;
            }
            var data = $("#form-user-add").serializeArray();
            $.operate.saveTab(prefix + "/add", data);
	    }

    </script>
</body>
</html>